import moment from 'moment'
const date = {
	//转换时间
	transformation(data) {
		let result=''
		var minute = 1000 * 60;
		var hour = minute * 60;
		var day = hour * 24;
		var halfamonth = day * 15;
		var month = day * 30;
		var year =month*12
	let timeStamp = new Date().getTime()
    var diffValue = timeStamp - 1629427598*1000;
    if(diffValue < 0){return;}
    var monthC =diffValue/month;
    var weekC =diffValue/(7*day);
    var dayC =diffValue/day;
    var hourC =diffValue/hour;
	var yearC=diffValue/year;
	if(yearC>=1){
	    result="" + parseInt(yearC) + "年前";
	}else if(monthC>=1){
        result="" + parseInt(monthC) + "月前";
    }
    else if(weekC>=1){
        result="" + parseInt(weekC) + "周前";
    }
    else if(dayC>=1){
        result=""+ parseInt(dayC) +"天前";
    }
    else if(hourC>=1){
        result=""+ parseInt(hourC) +"小时前";
    }
    else{
		 result="刚刚";
	}
    return result;
	},
	phoneNumFilter (phone) {
	// 1字符串转化成数组
	let phoneArr = [...phone];
	let str=''
	// 2.将数组中的4-7位变成*
	phoneArr.map((res, index) => {
	if (index > 2 && index < 7) {
	str += '*';
	// return '*';
	} else {
	str += res;
	// return res;
	}
	});
	return str;
	}
}
export default date

